﻿/*
    Copyright 2010, 2011 Eric Wong
	contact@optimalcycling.com
	http://www.optimalcycling.com
	Optimal Cycling - Advanced power pacing program for cyclists
	
	This file is part of Optimal Cycling.

    Optimal Cycling is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Optimal Cycling is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Optimal Cycling.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _OBJECTIVE_FUNC_H_
#define _OBJECTIVE_FUNC_H_

#ifndef __OPENCL_VERSION__
	#include "Options.h"
	#include "Constants.h"
	#include "Vector.h"
	#include "Interpolate.h"
	#include "Integrator.h"
	#include "SolverParams.h"
	#include "Model.h"
	#include "PowerMetrics.h"
#endif

/// <summary>
/// Calculates the fitness value
/// </summary>
/// <returns></returns>
inline real ObjectiveFunc(
		__global real* time,
		__global const real* currPowerVals,
		__global const real2* powerLimits,

		__global const real4* iConstants,	// real Tol {s0}, Hmin {s1}, Hmax {s2}, Hstart {s3};
		const real currMaxTime,

		__global const SolverVars* solverVars,
		__global const PowerMetricsInfo* powerMetricsInfo,
		__global const real2* powerMetricsCriticals,

		__global const real4* coursePosPoints, 
		__global const real* coursePosLinear,
		const real coursePosLinearMax,
		__global const real4* coursePosDirection,
		__global const real4* coursePosInfo, 
		__global const real4* riderProp,
		__global const real4* wind, 
		__global const real4* climate,
		const sizeT numSimPoints,

		__global const real* dragCoeffWheelYawAngles,
		__global const real2* dragCoeffWheels, 
		const sizeT dragCoeffWheelsNumPts,

		__global const ModelInfo* modelInfo,
		
		__global real8* bestPowerResults,
		__global real8* bestKinematics	);


#endif		// _OBJECTIVE_FUNC_H_
